package com.workcell.workdata.xthings.service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.workcell.workdata.common.core.util.R;
import com.workcell.workdata.xthings.dto.CodeChainnumUpdateAliasVo;
import com.workcell.workdata.xthings.dto.CodeChainnumVo;
import com.workcell.workdata.xthings.dto.DataBaseAndRealTimeResult;
import com.workcell.workdata.xthings.entity.CodeChainnum;
import com.workcell.workdata.xthings.entity.CodeLevelGauge;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 二维码码库
 *
 * @author 廖博文
 * @date 2022-11-30 09:34:00
 */
public interface CodeChainnumService extends IService<CodeChainnum> {

    /**
     * 生成短链码
     *
     * @param saveChainNumVo
     * @return
     */
    Boolean saveCodeChainNumInfo(CodeChainnumVo.SaveChainNumVo saveChainNumVo) throws Exception;

    /**
     * 获取硬件列表清单
     *
     * @param type
     * @return
     */
    List<JSONObject> getHardewareList(String type);

    /**
     * 模糊查询分页
     *
     * @param selectChainNumVo
     * @return
     */
    Page<CodeChainnum> getCodeChainnumVaguePage(CodeChainnumVo.SelectChainNumVo selectChainNumVo);

    /**
     * 根据ID删除短链码信息
     *
     * @param id
     * @return
     */
    R removeCodeChainNumById(String id) throws Exception;

    /**
     * 查询硬件快照信息
     *
     * @param codeId
     * @return
     */
    Object getHardwareInfo(String codeId, String type);

    /**
     * 根据ID获取二维码
     *
     * @param ids
     * @return
     */
    List<JSONObject> getQrCodeById(List<String> ids);

    /**
     * 根据短链码获取二维码参数信息
     *
     * @param chainNum
     * @return
     */
    DataBaseAndRealTimeResult.DataChainNumResult getCodeInfoByChainNum(String chainNum);

    /**
     * 根据时间段和类型查询总数
     *
     * @param hardwareType
     * @param startTime
     * @param endTime
     * @return
     */
    Integer getByTypeAndCreateTime(String hardwareType, LocalDateTime startTime, LocalDateTime endTime);

    /**
     * 根据类型和状态查询总数
     *
     * @param hardwareType
     * @param useState
     * @return
     */
    Integer getByTypeAndUseState(String hardwareType, String useState);

    /**
     * 根据设备编号和设备类型查询
     *
     * @param deviceNo 设备编号
     * @param hardwareType 设备类型
     * @return
     */
    CodeChainnum getByDeviceNoAndHardwareType(String deviceNo, String hardwareType);

    Map<String, Object> deviceDetail(String deviceNo, String hardwareType);

    /**
     * 更新设备上下线状态
     * @return
     */
    void updateUseState();

    /**
     * 根据短链码和设备类型查询
     * @param chainNum
     * @param hardwareType
     * @return
     */
    CodeChainnum getByChainnumAndHardwareType(String chainNum, String hardwareType);

    /**
     * 根据厂家设备编号查找厂商编码
     * @param deviceNo
     * @param hardwareType
     * @return
     */
    CodeChainnum getByDeviceNo(String deviceNo, String hardwareType);

    boolean updateAliasByDeviceNo(CodeChainnumUpdateAliasVo codeChainnumUpdateAliasVo);

    CodeLevelGauge getCodeLevelGaugeInfo(String codeId);

	Boolean updateHardwareStatus(String deviceNo, String manufacturerCode, String status,String hardwareType);
}
